<?php  
class CKEditorHelper extends Helper { 

	var $helpers = Array('Html', 'Javascript'); 
	
    function load($id , $options_=array()) { 
        $options = array( 
                    'language'=>'en', 
                    //'uiColor'=>'#7E9DCC', 
                    //'toolbar'=>'Full',
                    'toolbar'=>array(
        					array('Source','Save','Preview','Print'),
        					array('Cut','Copy','Paste','PasteText','PasteFromWord','Undo','Redo'),
        					array('Find','Replace','SelectAll','SpellChecker','Scayt'),
        					array('Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'),
        					array('Bold','Italic','Underline','Strike','Subscript','RemoveFormat'),
        					array('NumberedList','BulletedList','Outdent','Indent','Blockquote','CreateDiv','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'),
        					array('Link','Unlink','Anchor','ajaxAutoSave'),
        					array('Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe'),
        					array('Styles','Format','Font','FontSize','TextColor','BGColor','Maximize','ShowBlock',)
        				) 
                    
                    ); 
        if(!empty($options_)) array_merge($options,$options_); 
        $did = ''; 
        foreach (explode('.', $id) as $v) { 
            $did .= Inflector::camelize($v); 
        }  
         $did = Inflector::humanize($did); 
        //$did.destroy(); 
        //$did = null; 
        $code = " if (CKEDITOR.instances['".$did."']) { 
                    CKEDITOR.remove(CKEDITOR.instances['".$did."']); 
                 }\n"; 
        $code .= "var ".$did." = CKEDITOR.replace( '".$did."',".$this->Javascript->object($options).");\n";
        $code .= "CKFinder.setupCKEditor(".$did.",'../js/ckfinder/') ;";
        return $this->Javascript->codeBlock($code);  
    } 
} 
?> 
